package com.game.element
{
	import com.game.element.cooldown.CoolDownSprite;
	import com.game.manager.LayerManager;
	import com.game.res.UIRescource;
	import com.interfaces.game.GlobalAPI;
	import com.interfaces.general.mangaer.ITick;
	
	import fl.core.UIComponent;
	
	import flash.display.DisplayObject;
	import flash.utils.getTimer;
	
	public class KuaiPaoSkill extends UIComponent implements ITick {
		
		protected var cooldown:CoolDownSprite = new CoolDownSprite;
		protected var skill_uic:DisplayObject = new (UIRescource.SKILL_ICON);
		private var startTime:Number =0;
		private var longTime:Number = 1000*60*10;
		
		public function KuaiPaoSkill() {
			super();
			this.width = this.height = 36;
			
			skill_uic.width = this.width;
			skill_uic.height = this.height;
			
			addChild(skill_uic);
			addChild(cooldown);
		}
		
		public function isCanUse():Boolean{
			return startTime == 0;
		}
		
		public function useing():void{
			if(isCanUse() == false){
				return;
			}
			
			GlobalAPI.tickManager.regeditTick(this);
			
			startTime = getTimer();
			cooldown.coolDown = longTime;
			
			var speedBuff:SpeedBuff = new SpeedBuff;
			speedBuff.useing(LayerManager.sceneView.playerView);
		}
		
		public function exce():void {
			cooldown.step();
			if(getTimer()<=startTime+longTime){
				return;
			}
			
			startTime = 0;
			GlobalAPI.tickManager.unRegeditTick(this);
		}
		
		public function set tickPriority(priority:int):void {
			
		}
		
		public function get tickPriority():int {
			return 0;
		}
	}
}